package com.oocl.zero.datahandle.dao.impl;

import java.util.Collection;
import java.util.Comparator;
import java.util.Date;
import java.util.Set;
import java.util.TreeSet;

import com.oocl.zero.datahandle.App;
import com.oocl.zero.datahandle.dao.CustomerDao;
import com.oocl.zero.datahandle.entity.Customer;

public class CustomerDaoImpl implements CustomerDao{

	@Override
	public Set<Customer> sortById() {
		Set<Customer> rs=new TreeSet<Customer>(new Comparator<Customer>() {
			@Override
			public int compare(Customer o1, Customer o2) {
				return o1.getId()-o2.getId();
			}
		});
		rs.addAll(App.getDatas());
		return rs;
	}

	@Override
	public Set<Customer> sortByBirth() {
		Set<Customer> rs=new TreeSet<Customer>(new Comparator<Customer>() {
			@Override
			public int compare(Customer o1, Customer o2) {
				return new Date(o1.getBirthday()).compareTo(new Date(o2.getBirthday()));
			}
		});
		rs.addAll(App.getDatas());
		return rs;
	}

}
